package com.subang.function.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.subang.common.annotation.Log;
import com.subang.common.core.controller.BaseController;
import com.subang.common.core.domain.AjaxResult;
import com.subang.common.enums.BusinessType;
import com.subang.function.domain.SbFamousQuoteNouns;
import com.subang.function.service.ISbFamousQuoteNounsService;
import com.subang.common.utils.poi.ExcelUtil;
import com.subang.common.core.page.TableDataInfo;

/**
 * 名言名词Controller
 * 
 * @author subei
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/function/nouns")
public class SbFamousQuoteNounsController extends BaseController
{
    @Autowired
    private ISbFamousQuoteNounsService sbFamousQuoteNounsService;

    /**
     * 查询名言名词列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SbFamousQuoteNouns sbFamousQuoteNouns)
    {
        startPage();
        List<SbFamousQuoteNouns> list = sbFamousQuoteNounsService.selectSbFamousQuoteNounsList(sbFamousQuoteNouns);
        return getDataTable(list);
    }

    /**
     * 导出名言名词列表
     */
    @PreAuthorize("@ss.hasPermi('function:nouns:export')")
    @Log(title = "名言名词", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SbFamousQuoteNouns sbFamousQuoteNouns)
    {
        List<SbFamousQuoteNouns> list = sbFamousQuoteNounsService.selectSbFamousQuoteNounsList(sbFamousQuoteNouns);
        ExcelUtil<SbFamousQuoteNouns> util = new ExcelUtil<SbFamousQuoteNouns>(SbFamousQuoteNouns.class);
        util.exportExcel(response, list, "名言名词数据");
    }

    /**
     * 获取名言名词详细信息
     */
    @PreAuthorize("@ss.hasPermi('function:nouns:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sbFamousQuoteNounsService.selectSbFamousQuoteNounsById(id));
    }

    /**
     * 新增名言名词
     */
    @PreAuthorize("@ss.hasPermi('function:nouns:add')")
    @Log(title = "名言名词", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SbFamousQuoteNouns sbFamousQuoteNouns)
    {
        return toAjax(sbFamousQuoteNounsService.insertSbFamousQuoteNouns(sbFamousQuoteNouns));
    }

    /**
     * 修改名言名词
     */
    @PreAuthorize("@ss.hasPermi('function:nouns:edit')")
    @Log(title = "名言名词", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SbFamousQuoteNouns sbFamousQuoteNouns)
    {
        return toAjax(sbFamousQuoteNounsService.updateSbFamousQuoteNouns(sbFamousQuoteNouns));
    }

    /**
     * 删除名言名词
     */
    @PreAuthorize("@ss.hasPermi('function:nouns:remove')")
    @Log(title = "名言名词", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sbFamousQuoteNounsService.deleteSbFamousQuoteNounsByIds(ids));
    }
}
